/**
 * Write By HQ_punan 2012.01.22
 * For Read and Write XML Files
 */


package com.huaqin.punan;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {
	public static final String TAG = "XMLActivity";
	public static final String FILE_PATH = "/data/app/backdata/";
	public static final String FILE_NAME = "salesinfo";
	
	private Button btn_write_xml;
	private Button btn_read_dom;
	private Button btn_read_sax;
	private Button btn_read_pull;
	private TextView tv_show_xml;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		btn_write_xml = (Button)findViewById(R.id.btn_write_xml);
		btn_read_dom = (Button)findViewById(R.id.btn_read_dom);
		btn_read_sax = (Button)findViewById(R.id.btn_read_sax);
		btn_read_pull = (Button)findViewById(R.id.btn_read_pull);
		tv_show_xml = (TextView)findViewById(R.id.tv_show_xml);
		
		btn_write_xml.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				
				String xml = WriteXMLFiles.generateXML("0", "300", "100");
				boolean write_flag = WriteXMLFiles.WriteXML(xml);
				
				tv_show_xml.setText("write_flag="+write_flag);
			}});
		
		btn_read_dom.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				
				String[] salesinfo = ReadXMLDom.ReadXMLFiles();
				String send_flag = salesinfo[0];
				String out_going = salesinfo[1];
				String in_coming = salesinfo[2];
				tv_show_xml.setText("send_flag="+send_flag+",out_going="+out_going+",in_coming="+in_coming);
			}});
		
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}
